ostree-prepare-root.service: Run earlier in initrd
authorJonathan Lebon <jonathan@jlebon.com>
Thu, 18 Oct 2018 20:44:05 +0000 (16:44 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Fri, 19 Oct 2018 15:41:10 +0000 (15:41 +0000)
Previously, we were preparing the root very late in the boot process;
right before we switch root. The issue with that is that most services
in the initrd that run `After=initrd-root-fs.target` expect that
`/sysroot` already points to the rootfs we'll be pivoting to. Running
this late violates that assumption.

This patch fixes this by making `ostree-prepare-root.service` instead
run right after `sysroot.mount` (the physical sysroot mounted by
systemd) but still before `initrd-root-fs.target` (which is the target
signalling that `/sysroot` is now valid and ready).

This should make it easier to integrate OSTree with other initrd
services such as Ignition.

Related: https://github.com/dustymabe/ignition-dracut/issues/20

Closes: #1759
Approved by: cgwalters

src/boot/dracut/module-setup.sh
src/boot/ostree-prepare-root.service

index 70364c4b66eee9229233a639b1ec59f95c12f3f1..4d12fae6a1fab3b151c3076676850e92d965f4aa 100755 (executable)
@@ -36,7 +36,7 @@ depends() {
 install() {
     dracut_install /usr/lib/ostree/ostree-prepare-root
     inst_simple "${systemdsystemunitdir}/ostree-prepare-root.service"
-    mkdir -p "${initdir}${systemdsystemconfdir}/initrd-switch-root.target.wants"
+    mkdir -p "${initdir}${systemdsystemconfdir}/initrd-root-fs.target.wants"
     ln_r "${systemdsystemunitdir}/ostree-prepare-root.service" \
-        "${systemdsystemconfdir}/initrd-switch-root.target.wants/ostree-prepare-root.service"
+        "${systemdsystemconfdir}/initrd-root-fs.target.wants/ostree-prepare-root.service"
 }
index 455afc3efe09b2f0e946954e5cb42bbfb8e20942..63357581aaf25557a749943d05ba390ab5612cf4 100644 (file)
@@ -22,9 +22,8 @@ DefaultDependencies=no
 ConditionKernelCommandLine=ostree
 ConditionPathExists=/etc/initrd-release
 OnFailure=emergency.target
-After=initrd-switch-root.target
-Before=initrd-switch-root.service
-Before=plymouth-switch-root.service
+After=sysroot.mount
+Before=initrd-root-fs.target
 
 [Service]
 Type=oneshot